package edu.zut.main.thread;

public class ThreadSleep {

    public static void main(String[] args) {
        DownThread downThread = new DownThread();
        new Thread(downThread).start();
    }
}
//利用线程休眠模拟倒计时10s
class DownThread implements Runnable{
    private int num = 10;
    @Override
    public void run() {
        while (true){
            System.out.println(num --);
            //线程的休眠   1s
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (num <= 0){
                break;
            }
        }
    }
}